<?php
/**
 * Created by PhpStorm.
 * User: sunku
 * Date: 2018/2/27
 * Time: 9:49
 */

namespace Resource\Service;
use Think\Model;
use Common\ORG\Util\AuthTable;


class UserDepartmentService extends Model
{
    protected $trueTableName = AuthTable::TB_AUTH_USER_DEPARTMENT;


    /**
     * 查询用户关联的应用id列表
     * @param $user_id
     * @return array
     */
    public function getUserRelationDepartmentIdList($user_id) {
        $userDepartmentList = D('Resource/UserDepartment')->getUserRelationDepartmentList($user_id);

        $userDepartmentIdList = [];
        if(is_array($userDepartmentList) && count($userDepartmentList) > 0) {
            foreach ($userDepartmentList as $Department) {
                $userDepartmentIdList[] = $Department['department_id'];
            }
        }

        return $userDepartmentIdList;
    }

    /**
     * 查询用户关联的部门列表
     * @param $user_id
     * @return mixed
     */
    public function getUserRelationDepartmentList($user_id) {
        $userDepartmentList = D('Resource/UserDepartment')->getUserRelationDepartmentList($user_id);
        return $userDepartmentList;
    }

    /**
     * 删除用户关联的部门
     * @param $user_id
     * @return mixed
     */
    public function deleteUserRelationDepartment($user_id) {
        return D('Resource/UserDepartment')->deleteUserRelationDepartment($user_id);
    }

    /**
     * 添加用户关联的应用
     * @param $params
     * @return mixed
     */
    public function addUserRelationDepartment($params) {
        return D('Resource/UserDepartment')->addUserRelationDepartment($params);
    }

}